/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ConsultaEleccion.java
 *
 * Created on 14/11/2010, 05:00:15 PM
 */
package zonasoft.Vistas.Funcionales;

import com.mysql.jdbc.Connection;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.util.Date;
import java.util.Map;
import javax.swing.JOptionPane;
//import zonasoft.Conceptos.firmante;
import javax.swing.JTextField;
import zonasoft.Conceptos.Eleccion;
import zonasoft.Conceptos.Lider;
import zonasoft.Conceptos.Usuario;
import zonasoft.Manejadores.ManejadorBaseDatos;
//import zonasoft.Manejadores.ManejadorSimpatizante;
import zonasoft.Manejadores.ManejadorEleccion;
import zonasoft.Manejadores.ManejadorLider;
import zonasoft.Manejadores.ManejadorPuesto;
import zonasoft.Manejadores.ManejadorUsuario;
import zonasoft.Vistas.inicioSesion;

/**
 *
 * @author JORGE
 */
public class ConsultaLider extends javax.swing.JDialog {

    /** Creates new form ConsultaEleccion */
    
    public ConsultaLider(java.awt.Frame parent) {
        super(parent, true);
        initComponents();
        pack();
        Rectangle parentBounds = parent.getBounds();
        Dimension size = getSize();
        // Center in the parent
        int x = Math.max(0, parentBounds.x + (parentBounds.width - size.width) / 2);
        int y = Math.max(0, parentBounds.y + (parentBounds.height - size.height) / 2);
        setLocation(new Point(x, y));

        habilitar.setVisible(false);
        deshabilitar.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXTaskPaneContainer1 = new org.jdesktop.swingx.JXTaskPaneContainer();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        campoId = new javax.swing.JTextField();
        campoNombre = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        campoEmail = new javax.swing.JTextField();
        campoCelular = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        campoEdad = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        campoDireccion = new javax.swing.JTextArea();
        campoSexo = new javax.swing.JTextField();
        campoBarrio = new javax.swing.JTextField();
        campoCorreo = new javax.swing.JTextField();
        jXPanel1 = new org.jdesktop.swingx.JXPanel();
        consultar = new javax.swing.JButton();
        aceptar = new javax.swing.JButton();
        BotonLimpiar = new javax.swing.JButton();
        deshabilitar = new javax.swing.JButton();
        habilitar = new javax.swing.JButton();
        jXPanel3 = new org.jdesktop.swingx.JXPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        campoMesa = new javax.swing.JTextField();
        campoPuesto = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        direccionPuesto = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        labelUsuario = new javax.swing.JLabel();
        fecg = new org.jdesktop.swingx.JXDatePicker();
        jPanel3 = new javax.swing.JPanel();
        campoBarrio1 = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        ucg = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        ucg1 = new javax.swing.JLabel();
        campoBarrio2 = new javax.swing.JTextField();
        franja = new javax.swing.JTextField();

        setTitle("");

        jLabel1.setFont(new java.awt.Font("Lucida Bright", 1, 18));
        jLabel1.setText("Consulta de Lideres");
        jXTaskPaneContainer1.add(jLabel1);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.gray, java.awt.Color.lightGray, java.awt.Color.darkGray, java.awt.Color.gray), "Datos Lideres", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Bright", 1, 12))); // NOI18N

        jLabel3.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel3.setText("Lider");

        jLabel4.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel4.setText("Telefono");

        jLabel2.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel2.setText("Identificacion");

        campoId.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoIdActionPerformed(evt);
            }
        });
        campoId.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoIdKeyTyped(evt);
            }
        });

        campoNombre.setEditable(false);

        jLabel5.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel5.setText("Barrio");

        campoEmail.setEditable(false);

        campoCelular.setEditable(false);

        jLabel7.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel7.setText("Edad:");

        campoEdad.setEditable(false);

        jLabel8.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel8.setText("Direccion:");

        jLabel6.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel6.setText("Profesion");

        jLabel9.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel9.setText("Sexo");

        jLabel10.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel10.setText("Correo");

        campoDireccion.setColumns(20);
        campoDireccion.setEditable(false);
        campoDireccion.setRows(5);
        jScrollPane1.setViewportView(campoDireccion);

        campoBarrio.setEditable(false);

        campoCorreo.setEditable(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel5)
                    .addComponent(jLabel9)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(campoBarrio, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                    .addComponent(campoCelular, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                    .addComponent(campoSexo, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(campoNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                        .addComponent(campoId, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)))
                .addGap(32, 32, 32)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel10))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(campoEdad, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
                        .addGap(116, 116, 116))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(campoCorreo, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(campoEmail, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)))
                .addGap(60, 60, 60))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(campoId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(campoNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(campoEdad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel6)
                    .addComponent(campoEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(campoCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel10)
                        .addComponent(campoCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(campoBarrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel8))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        jXPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, java.awt.Color.lightGray, java.awt.Color.lightGray, java.awt.Color.gray, java.awt.Color.gray));

        consultar.setFont(new java.awt.Font("Lucida Bright", 1, 12));
        consultar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/search-icon2.png"))); // NOI18N
        consultar.setText(" consultar");
        consultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                consultarActionPerformed(evt);
            }
        });

        aceptar.setFont(new java.awt.Font("Lucida Bright", 1, 12));
        aceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/ok 32.png"))); // NOI18N
        aceptar.setText("Aceptar");
        aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aceptarActionPerformed(evt);
            }
        });

        BotonLimpiar.setFont(new java.awt.Font("Lucida Bright", 1, 12));
        BotonLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/limpiar.png"))); // NOI18N
        BotonLimpiar.setText("Limpiar");
        BotonLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonLimpiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jXPanel1Layout = new javax.swing.GroupLayout(jXPanel1);
        jXPanel1.setLayout(jXPanel1Layout);
        jXPanel1Layout.setHorizontalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(consultar, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                    .addComponent(aceptar, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                    .addComponent(BotonLimpiar, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE))
                .addContainerGap())
        );
        jXPanel1Layout.setVerticalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(consultar, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(aceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BotonLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11))
        );

        deshabilitar.setFont(new java.awt.Font("Lucida Bright", 1, 12));
        deshabilitar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/lock-icon2.png"))); // NOI18N
        deshabilitar.setText("Deshabilitar");
        deshabilitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deshabilitarActionPerformed(evt);
            }
        });

        habilitar.setFont(new java.awt.Font("Lucida Bright", 1, 12));
        habilitar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/lock-off-icon2.png"))); // NOI18N
        habilitar.setText("Habilitar");
        habilitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                habilitarActionPerformed(evt);
            }
        });

        jXPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Electorales", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        jLabel14.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel14.setText("Puesto de Votacion");

        jLabel15.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel15.setText("# Mesa");

        jLabel16.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel16.setText("Direccion ");

        campoMesa.setEditable(false);

        campoPuesto.setEditable(false);

        direccionPuesto.setColumns(20);
        direccionPuesto.setEditable(false);
        direccionPuesto.setRows(5);
        jScrollPane3.setViewportView(direccionPuesto);

        javax.swing.GroupLayout jXPanel3Layout = new javax.swing.GroupLayout(jXPanel3);
        jXPanel3.setLayout(jXPanel3Layout);
        jXPanel3Layout.setHorizontalGroup(
            jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel3Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE))
                    .addComponent(jLabel14)
                    .addComponent(campoPuesto, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE))
                .addGroup(jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel3Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(jLabel15))
                    .addGroup(jXPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoMesa, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jXPanel3Layout.setVerticalGroup(
            jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel3Layout.createSequentialGroup()
                .addGroup(jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoPuesto, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(campoMesa, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addGap(46, 46, 46))
                    .addGroup(jXPanel3Layout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
                        .addContainerGap())))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Auditoria", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        jLabel11.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel11.setText("Ingresado por");

        jLabel12.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel12.setText("el");

        labelUsuario.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        fecg.setEditable(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(labelUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(fecg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(26, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labelUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(fecg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Analisis Electoral", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        campoBarrio1.setEditable(false);

        jLabel26.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel26.setText("Reside en:");

        ucg.setText("ucg");

        jLabel27.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel27.setText("Vota en:");

        ucg1.setText("ucg");

        campoBarrio2.setEditable(false);

        franja.setEditable(false);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel26)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ucg, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE))
                            .addComponent(campoBarrio1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(campoBarrio2, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel27)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(ucg1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addComponent(franja, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(ucg, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel27)
                    .addComponent(ucg1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoBarrio1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(campoBarrio2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(franja, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.PREFERRED_SIZE, 917, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jXPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(deshabilitar, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(habilitar, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(32, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(jXPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(habilitar, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deshabilitar, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jXPanel3, 0, 130, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, 0, 130, Short.MAX_VALUE)
                        .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(31, 31, 31))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void consultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_consultarActionPerformed
        // TODO add your handling code here:
        ManejadorBaseDatos manejabd = ManejadorBaseDatos.getInstancia();
        try {
            manejabd.conectar();
            //ManejadorSimpatizante.conm=manejabd.getConexion();
            ManejadorLider.conm = manejabd.getConexion();
            ManejadorEleccion.conm=manejabd.getConexion();
               ManejadorPuesto.con = (Connection) manejabd.getConexion();
            ManejadorUsuario.conm = manejabd.getConexion();
              Map<String, String> resultados = null;
            //firmante f = new firmante();
            Lider li = new Lider();
       
//            Eleccion el=new Eleccion();
            //f = ManejadorSimpatizante.getFirmante(campoId.getText());
            li = ManejadorLider.getLider(campoId.getText().trim());
            //el=ManejadorEleccion.getEleccion(li.getIdEleccion());
//            if(li.getNombre().endsWith("_"))
//            {
//               habilitar.setEnabled(true);
//               deshabilitar.setEnabled(false);
//            }
//            else
//            {
//                deshabilitar.setEnabled(true);
//                habilitar.setEnabled(false);
//            }
         if (!campoId.getText().isEmpty()) {
            if (li != null) {
                campoNombre.setText(li.getNombre().replace("_", "")+" "+li.getApellido());
                campoEmail.setText(li.getCorreo());
                campoCelular.setText(li.getTelefono());
//                campoEleccion.setText(el.getNombre()+ " "+el.getPeriodoInicio()+"-"+el.getPeriodoFin());
                campoDireccion.setText(li.getDireccion());
                if(li.getSexo()==0){
                campoSexo.setText("Masculino");
                }else{
                campoSexo.setText("Femenino");
                }
                Date fechaHoy = new Date();      
                int edad=0 ;
                edad = fechaHoy.getYear()-li.getFechaNacimiento().getYear();
                campoEdad.setText(String.valueOf(edad));
                campoBarrio.setText(li.getBarrio());
                campoCorreo.setText(li.getCorreo());
                 
               resultados = ManejadorLider.getDatosVotacion(li.getIdPuesto());
//                 System.out.println("resultados.get(barrio)= " + resultados.get("barrio"));
//                 System.out.println("resultados.get(puesto) = " + resultados.get("puesto"));
                    if (resultados != null) {
                        campoPuesto.setText(resultados.get("puesto"));
                        campoMesa.setText(li.getMesa());
                        direccionPuesto.setText(resultados.get("barrio"));
                        // Parte de la franja
                        campoBarrio1.setText(li.getBarrio());
                        campoBarrio2.setText(resultados.get("barrio"));

                        boolean answer = false;
                        int terceraRespuesta = -1;
                        Map<String, Integer> unidadesByBarrio = null;

                        Object[] resultado = ManejadorLider.validarZonificacion(li.getBarrio(), resultados.get("barrio"));

                        unidadesByBarrio = (Map<String, Integer>) resultado[0];
                        answer = (Boolean) resultado[1];
//                        System.out.println("answer = " + answer);
                        terceraRespuesta = (Integer) resultado[2];
                        if (answer == true) {
                            franja.setBackground(Color.GREEN);
                        } else {
                            franja.setBackground(Color.red);
                        }

                        if (terceraRespuesta == 0) {
                            ucg.setText("UCG #" + String.valueOf(unidadesByBarrio.get(li.getBarrio().toLowerCase())));
                            ucg1.setText("UCG #" + String.valueOf(unidadesByBarrio.get(resultados.get("barrio").toLowerCase())));
                        } else {
                            ucg.setText(String.valueOf(terceraRespuesta));
                            ucg1.setText(String.valueOf(terceraRespuesta));
                        }
                        //              // usuario
                        Usuario us = null;
                        us = inicioSesion.userActual;
                        labelUsuario.setText(us.getLogin_usuario());

                        java.util.Date fechaC = new java.util.Date(li.getFechaCreacion().getTime());
//                  labelFecha.setText(fechaC);
                        fecg.setDate(fechaC);

                    }

        
            } else {
                JOptionPane.showMessageDialog(null, " Busqueda sin resultados", "Busqueda sin resultados", JOptionPane.INFORMATION_MESSAGE);
                limpiar();
            }
       } else {
                JOptionPane.showMessageDialog(null, "Por favor digite la identificacion", "Campo Vacio", JOptionPane.WARNING_MESSAGE);
            }

        } catch (Exception ex) {
            // Logger.getLogger(ConsultaEleccion.class.getName()).log(Level.SEVERE, null, ex);
//            JOptionPane.showMessageDialog(null, " Este Lider no Existe", "Busqueda sin resultados", JOptionPane.INFORMATION_MESSAGE);
            ex.printStackTrace();
        }

    }//GEN-LAST:event_consultarActionPerformed

    private void aceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aceptarActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_aceptarActionPerformed

    private void habilitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_habilitarActionPerformed
        // TODO add your handling code here:
         ManejadorBaseDatos manejabd = ManejadorBaseDatos.getInstancia();
        try {
            manejabd.conectar();
            //ManejadorSimpatizante.conm=manejabd.getConexion();
            ManejadorLider.con = manejabd.getConexion();
            //firmante f = new firmante();
           Lider li = new Lider();
            //f = ManejadorSimpatizante.getFirmante(campoId.getText());
            li = ManejadorLider.getLider(campoId.getText());
//              us=inicioSesion.userActual;

            if (li != null) {
                ManejadorLider.updateLiderDeshabilitar(li,campoId.getText(),1);
                JOptionPane.showMessageDialog(null, "Lider habilitado correctamente", "Actualizacón correcta", JOptionPane.INFORMATION_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(null, "El Lider fue habilitado", "Actualizacón correcta", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (Exception ex) {
            // Logger.getLogger(ConsultaEleccion.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, " Error en la insercion en la DB", "Actualización Fallida", JOptionPane.INFORMATION_MESSAGE);
            ex.printStackTrace();
        }
    }//GEN-LAST:event_habilitarActionPerformed

    private void campoIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoIdActionPerformed
        // TODO add your handling code here:
        consultarActionPerformed(evt) ;

    }//GEN-LAST:event_campoIdActionPerformed

    private void deshabilitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deshabilitarActionPerformed
        // TODO add your handling code here:
        ManejadorBaseDatos manejabd = ManejadorBaseDatos.getInstancia();
        try {
            manejabd.conectar();
            //ManejadorSimpatizante.conm=manejabd.getConexion();
            ManejadorLider.conm = manejabd.getConexion();
            //firmante f = new firmante();
           Lider li = new Lider();
                        //f = ManejadorSimpatizante.getFirmante(campoId.getText());
            li = ManejadorLider.getLider(campoId.getText());
            //              us=inicioSesion.userActual;

            if (li != null) {
                ManejadorLider.updateLiderDeshabilitar(li, campoId.getText(),0);
                JOptionPane.showMessageDialog(null, "Lider Deshabilitado correctamente", "Actualizacón correcta", JOptionPane.INFORMATION_MESSAGE);
            } else {
//                JOptionPane.showMessageDialog(null, "El usuario fue deshabilitado", "Actualizacón correcta", JOptionPane.INFORMATION_MESSAGE);
            }




        } catch (Exception ex) {
            // Logger.getLogger(ConsultaEleccion.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, " Error en la insercion en la DB", "Actualización Fallida", JOptionPane.INFORMATION_MESSAGE);
            ex.printStackTrace();
        }
    }//GEN-LAST:event_deshabilitarActionPerformed

    private void BotonLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonLimpiarActionPerformed
        // TODO add your handling code here:
        limpiar();
        campoId.requestFocus();
}//GEN-LAST:event_BotonLimpiarActionPerformed

    private void campoIdKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoIdKeyTyped
        // TODO add your handling code here:
           validaNumeros(evt, campoId,20);
    }//GEN-LAST:event_campoIdKeyTyped

    
    
       public void limpiar() {
    campoId.setText("");
    campoNombre.setText("");
    campoCelular.setText("");
    campoEdad.setText("");
    campoDireccion.setText("");
    campoEmail.setText("");
    campoPuesto.setText("");
    campoMesa.setText("");
    campoSexo.setText("");
    campoCorreo.setText("");
    campoBarrio.setText("");
    
//    campoBarrio1.setText("aca estoy");
//    campoBarrio2.setText("aca estoy");
    }
    
          private void validaNumeros(java.awt.event.KeyEvent evt, JTextField campo, int numero) {
        int caracter = (int) evt.getKeyChar();
        char letra = ((char) caracter);
        
         int n = campo.getText().length() + 1;
         if(n > numero){evt.setKeyChar((char)KeyEvent.VK_CLEAR); campo.setToolTipText(("<html> <center> <h1> Advertencia </h1>"                  + "<h2 Style='color: red; font-style: italic;'> No puede superar la cantidad de caracteres permitidos </h2>"
                  + "<b>" + --n +" <br/> Es el maximo  para este campo </b> </center>"
                  + "<br/> Compruebe sus datos."));}

            //           solo numeros               retroceso       ctrl+c           ctrl + v          ctrl + x          supri                  -
        if (caracter >= 48 && caracter <= 57 || caracter == 8 || caracter == 3 || caracter == 22 || caracter == 24 || caracter == 27 || caracter == 45) {
        } else {
//        int numeropermitido = campo.getText().length();
            evt.setKeyChar((char) KeyEvent.VK_CLEAR);
            campo.setToolTipText(("<html> <center> <h1> Advertencia </h1>"
                    + "<h2 Style='color: red; font-style: italic;'> Ingrese numeros por favor </h2>"
                    + "<b> " + letra + "<br/> no es un numero </b> </center>"
                    + "<br/> Compruebe sus datos."));
        }
    }
       
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotonLimpiar;
    private javax.swing.JButton aceptar;
    private javax.swing.JTextField campoBarrio;
    private javax.swing.JTextField campoBarrio1;
    private javax.swing.JTextField campoBarrio2;
    private javax.swing.JTextField campoCelular;
    private javax.swing.JTextField campoCorreo;
    private javax.swing.JTextArea campoDireccion;
    private javax.swing.JTextField campoEdad;
    private javax.swing.JTextField campoEmail;
    private javax.swing.JTextField campoId;
    private javax.swing.JTextField campoMesa;
    private javax.swing.JTextField campoNombre;
    private javax.swing.JTextField campoPuesto;
    private javax.swing.JTextField campoSexo;
    private javax.swing.JButton consultar;
    private javax.swing.JButton deshabilitar;
    private javax.swing.JTextArea direccionPuesto;
    private org.jdesktop.swingx.JXDatePicker fecg;
    private javax.swing.JTextField franja;
    private javax.swing.JButton habilitar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private org.jdesktop.swingx.JXPanel jXPanel1;
    private org.jdesktop.swingx.JXPanel jXPanel3;
    private org.jdesktop.swingx.JXTaskPaneContainer jXTaskPaneContainer1;
    private javax.swing.JLabel labelUsuario;
    private javax.swing.JLabel ucg;
    private javax.swing.JLabel ucg1;
    // End of variables declaration//GEN-END:variables
}
